<template>
  <div>
    <h3>添加工作区组件</h3>
    <el-select v-model="selectedComponent" placeholder="选择组件">
      <el-option
        v-for="item in componentList"
        :key="item.value"
        :label="item.label"
        :value="item.value">
      </el-option>
    </el-select>
    <el-button @click="handleAdd" style="margin-top: 15px;">添加</el-button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      selectedComponent: '',
      componentList: [
        { label: '代码片段', value: 'CodeSnippets' },
        { label: '时间追踪', value: 'TimeTracker' }
      ]
    }
  },
  methods: {
    handleAdd() {
      if (this.selectedComponent) {
        this.$emit('add-component', () => import(`../widgets/${this.selectedComponent}.vue`))
      }
    }
  }
}
</script>